{extend name="common/__base" /}
{block name="body"}
<form class="layui-form layui-form-pane">
    <div class="layui-form-item">
        <label class="layui-form-label">所属菜单</label>
        <div class="layui-input-block">
            <select name="pid">
                <option value="0">顶级菜单</option>
                {volist name="oneMenuList" id="vo"}
                <option value="{$vo.id}">{$vo.title}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" class="layui-input" placeholder="请输入菜单名称">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">菜单路由</label>
        <div class="layui-input-block">
            <input type="text" name="name" class="layui-input" placeholder="请输入菜单路由">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="sort" value="9" class="layui-input" placeholder="请输入排序">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图标</label>
        <div class="layui-input-block">
            <input type="text" name="icon" class="layui-input" placeholder="请输入图标">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否显示</label>
        <div class="layui-input-block">
            <input type="checkbox" name="is_show" value="1" lay-skin="switch" lay-text="显示|隐藏" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="submit" id="submit">添加</button>
            <button class="layui-btn layui-btn-primary" type="reset">重置</button>
        </div>
    </div>
</form>
{/block}

{block name="js"}
<script>
    // 表单提交
    $("#submit").click(function () {
        $.ajax({
            url: "{:url('admin/system/addMenu')}",
            type: "post",
            data: $("form").serialize(),
            dataType: "json",
            success: function (ret) {
                if (ret.code == 1) {
                    layer.msg(ret.msg, {time: 2000}, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(ret.msg);
                }
            }
        });
        return false;
    });
</script>
{/block}